<%@page import="multiface.valentinorusso.jpa.File"%>
<%@page import="multiface.valentinorusso.jpa.Lavoro"%>
<%@page import="java.util.List"%>
<%@page import="multiface.valentinorusso.jpa.Categoria"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="multiface.valentinorusso.jpa.util.PersistenceManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%
    EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
    EntityManager em = emf.createEntityManager();

    String id = request.getParameter("id");
    
    Lavoro lav = em.find(Lavoro.class, Integer.parseInt(id));
    em.refresh(lav);
    
    String title = lav.getCategoria().getNome() + " > " + lav.getNome();
%>
<script>
    $(document).ready(function() {
        $("a.lavori").fancybox({
            'transitionIn' : 'none',
            'transitionOut':  'none',
            'titlePosition' 	: 'over',
            'overlayOpacity'    : '0.7',
            'overlayColor'      : '#000',
            'type' : 'image',
            'titleShow': true
        });
    });
</script>
<style>
    .box-image{
        margin-top: 6px;
        margin-right: 6px;
        margin-bottom: 6px;
        margin-left: 0px;
        height: 120;
        width: 140;
        float: left;
    }
    .title{
        padding: 6px;
        font-size: 16px;
    }
    .desc{
        padding: 6px;
    }
</style>

<div id="center" style="width: 620px;">

    <div class="title"><%=title%> </div>
    <div class="desc"><%=lav.getDescrizione()%> </div>
    <%
        for (File f: lav.getFileList()) {
            em.refresh(f);
    %>
    <div class="box-image">
        <%
            String src =  "GetImageServlet?th=y&fid=" + f.getIdfile();
        %>
        <a rel="gruppo1" class="lavori" href="GetImageServlet?fid=<%=f.getIdfile()%>"><img src="<%=src%>" width="120" height="90" /></a>
    </div>
    <%
        }
    %>
</div>